"""demo."""
from io import open

import scrapy


class QuotesSpider(scrapy.Spider):
    """demo."""
    name = 'quotes'

    def start_requests(self):
        """demo."""
        urls = [
            'http://quotes.toscrape.com/page/1/',
            'http://quotes.toscrape.com/page/2/',
        ]
        for url in urls:
            yield scrapy.Request(url=url,callback=self.parse)

    def parse(self, response):
        """demo"""
        page = response.url.split("/")[-2]
        filename = 'Quotes-%s.html' % page
        with open(filename, 'wb') as f:
            f.write(response.body)
        self.log('Saved file %s' % filename)
